#!/usr/bin/env bash

set -x
set -e

# https://docs.fastlane.tools/actions/deliver/#available-language-codes
APP_STORE_LANGUAGES='ar,ca,cs,da,de,el,en_AU,en_CA,en_GB,en_US,es_ES,es_MX,fi,fr_CA,fr_FR,he,hi,hr,hu,id,it,ja,ko,ms,nl,no,pl,pt_BR,pt_PT,ro,ru,sk,sv,th,tr,uk,vi,zh_CN,zh_TW'

echo "Pulling metadata translations..."

BASE_DIR=$(git rev-parse --show-toplevel)
METADATA_ROOT="$BASE_DIR/fastlane/metadata"

cd $METADATA_ROOT

# Pull all supported languages which are 100% complete
tx pull -l $APP_STORE_LANGUAGES --minimum-perc=100

# Legacy hack: pull *any existing* app store descriptios regardless of their completion.
# Once supported, we don't want to drop any translations.
tx pull --force -l $APP_STORE_LANGUAGES
